package com.caac.core.config;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.hibernate.criterion.Criterion;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright caac 2006</p>
 * <p>Company: caac</p>
 * @author <a href="mailto:project@caac.com.cn">Project Group</a>
 * @version 1.0
 */

public class DmProperty extends Conf {
    private Operator operator;
    private Alias alias;
    private List list = new ArrayList();

    public void setName(String name) {
        super.setName(name);
        this.alias = AliasHelper.getAlias(name);
    }

    public void setOperator(String operator) {
        this.operator = Config.getInstance().getOperator(operator);
    }

    public Alias getAlias() {
        return alias;
    }

    public void addChild(QueryProperty qp) {
        list.add(qp);
    }

    public QueryProperty getChild(int index) {
        return (QueryProperty) list.get(index);
    }

    public void init(Object bean, Map aliasMap, Map propMap) {
        operator.init(bean, aliasMap, propMap, this);
    }

    public Criterion getCriterion(Map propMap) {
        return operator.getCriterion(propMap, this);
    }
}
